package de.tabuma.pm.gadget.view;

import de.tabuma.lib.tabumaview;
import de.tabuma.pm.*;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class view extends tabumaview {
    public view(String servlet, Hashtable hashtable) {
        super(servlet, hashtable);
    }
    
    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        String gadget = "gadget list";



        
        out.println("<div class=\"contentContent\">");
        out.println("<div class=\"contentBoxed\">");
        out.println("<div class=\"contentHeader\"><a name=\"" + constants.gadgetA + "\">" + gadget + "</a></div>");
        out.println("<div class=\"contentContent\">");
        String id = (String) request.getAttribute(constants.gadgetActionId);
        if(id==null) {
            id = "0";
        }
        int idInt = Integer.valueOf(id).intValue();
        switch(idInt) {
            case constants.GADGET_ACTION_CREATE:
                create create = new create(this.getServlet(), this.getParameter());
                create.processRequest(context, request, response, out);
                break;
            case constants.GADGET_ACTION_SETTING:
                Hashtable hash = this.getParameter();
                hash.put(constants.gadgetActionId, ""+constants.GADGET_ACTION_SETTING);
                settings setting = new settings(this.getServlet(), hash);
                setting.processRequest(context, request, response, out);
                break;
            case constants.GADGET_ACTION_UPDATE:
                update update = new update(this.getServlet(), this.getParameter());
                update.processRequest(context, request, response, out);
                break;
            default:
                list list = new list(this.getServlet(), this.getParameter());
                list.processRequest(context, request, response, out);
        }
        out.println("</div>");
        out.println("</div>");
        out.println("</div>");
    }
}